classdef AnalogFilterBuilder < handle % Main class - Unify all GUI stages
   
    properties
        StageGUI = {};
    end
    
    methods
        
        function this = AnalogFilterBuilder 
            
            this.StageGUI{1} = AnalogFilterDesign;
            this.StageGUI{2} = AnalogFilterDesign2;
            this.StageGUI{3} = AnalogFilterDesign3;
            
            addlistener(this.StageGUI{1}, 'actualGUI', 'PostSet', @this.changeStage);
            addlistener(this.StageGUI{2}, 'actualGUI', 'PostSet', @this.changeStage);
            addlistener(this.StageGUI{3}, 'actualGUI', 'PostSet', @this.changeStage);
            
            guidata(this.StageGUI{1}.handles.mainMenu, this.StageGUI);
            guidata(this.StageGUI{2}.handles.mainMenu, this.StageGUI);
            guidata(this.StageGUI{3}.handles.mainMenu, this.StageGUI);
            
            this.StageGUI{1}.visible(1);
            this.StageGUI{2}.visible(1);
            this.StageGUI{3}.visible(1);
        end
        
        function delete(this)
            delete(this.StageGUI{1});
            delete(this.StageGUI{2});
            delete(this.StageGUI{3});
        end
    end
    
    methods (Static)
        function changeStage(~, event)
            Stage = guidata(event.AffectedObject.handles.mainMenu);
            actualGUI = floor(event.AffectedObject.actualGUI);
            switch actualGUI
                case 1
                    ;
                case 2
                    Stage{2}.setFilterData(Stage{1}.filterList{get(Stage{1}.handles.filterListMenu, 'Value')});
                case 3
                    Stage{3}.setStagesData(Stage{2}.filterData, Stage{2}.stagesList, Stage{2}.totalAttenuation);
            end
            for i = 1:3
                Stage{i}.visible(actualGUI);
            end 
        end
    end
end